package first.niuke.huawei.mediumDifficulty;

import java.util.Stack;

/**
 * @ClassName HJ57
 * @description:
 * @author: 荣燊
 * @create: 2021-07-08 12:57
 **/
public class HJ57 {
    // 高精度整数加法

    public static void main(String[] args) {
        // 栈，没考虑负数
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            String s1 = scanner.nextLine();
//            String s2 = scanner.nextLine();

            String s1 = "623192091";
            String s2 = "14426202982932";

            Stack<Integer> stack = new Stack<>();
            int i = s1.length()-1;
            int j = s2.length()-1;
            int flag = 0;

            while (i >= 0 || j >= 0) {
                char c1 = '0';
                char c2 = '0';
                int result = 0;
                if (i >= 0) {
                    c1 = s1.charAt(i);
                }
                if (j >= 0) {
                    c2 = s2.charAt(j);
                }
                result = (c1 - 48) + (c2 - 48) + flag;
                if (result > 9) {
                    result = result % 10;
                    flag = 1;
                } else {
                    flag = 0;
                }
                stack.push(result);
                i--;
                j--;
            }
            if (flag == 1) {
                stack.push(1);
            }
            while (!stack.empty()) {
                System.out.print(stack.pop());
            }
            System.out.println();
        }
//    }
}
